<style>
    .check {
        padding-right: 5px;
        display: inline-block;
    }

    .check input[type=checkbox], .check label {
        cursor: pointer;
    }
</style>
<form id="bed" action="" method="POST">
    <table class="table table-striped">
        <thead>
        <tr>
            <th>{:__('Name')}</th>
            <th>
                {$school['name']}
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>{:__('Gender')}</td>
            <td>
                {$gender_text}
            </td>
        </tr>
        <tr>
            <td>{:__('未入住人数')}</td>
            <td>
                {$student_count}
            </td>
        </tr>
        <tr>
            <td>园区/楼栋</td>
            <td>
                <div class="form-inline" data-toggle="cxselect" data-selects="garden,building">
                    <select class="form-control garden" name="garden_number"
                            data-url="common/gardens?school_id={$school['id']}"></select>
                    <select class="form-control building" name="building_number"
                            data-url="common/buildingsByNumber?school_id={$school['id']}" data-query-name="garden_number"></select>
                </div>
            </td>
        </tr>

        <tr>
            <td>已选床位</td>
            <td>
                <span id="selected_bed_count">0</span>个
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="floor_list"></div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="dorm_list"></div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div id="bed_list"></div>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="hide layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <input type="hidden" id="school_id" name="school_id" value="{$school['id']}">
            <input type="hidden" id="gender" name="gender" value="{$gender}">
            <button type="button" class="btn btn-primary btn-back">{:__('上一步')}</button>
            <button type="submit" class="btn btn-success">{:__('Save')}</button>
        </div>
    </div>
</form>

<script type="text/html" id="floor_tpl">

    <% if(floor.length > 0){ %>
    <%for(var i=0; i< floor.length; i++){%>
    <span class="check">
        <input id="floor_<%=floor[i]%>" class="floor" name="floor[]" type="checkbox" value="<%=floor[i]%>">
        <label for="floor_<%=floor[i]%>"><%=floor[i]%>楼</label>
    </span>
    <%}%>
    <%}else{%>
    <span>暂无数据</span>
    <%}%>

</script>

<script type="text/html" id="dorm_tpl">

    <%for(var i=0; i< dorm.length; i++){%>
    <span class="check">
            <input id="dorm_<%=dorm[i].number%>" class="dorm dorm_<%=dorm[i].number%>" name="dorm[]" type="checkbox"
                   value="<%=dorm[i].number%>">
            <label for="dorm_<%=dorm[i].number%>"><%=dorm[i].name%> 剩余<%=dorm[i].bed_unused_count%>个床位</label>
        </span>
    <%}%>

</script>
<script type="text/html" id="bed_tpl">

    <%for(var i=0; i< bed.length; i++){%>
    <span class="check">
            <input id="bed_<%=bed[i].id%>" class="bed bed_<%=bed[i].dorm_number%>" name="bed[]" type="checkbox"
                   data-dorm-number="<%=bed[i].dorm_number%>" value="<%=bed[i].id%>">
            <label for="bed_<%=bed[i].id%>"><%=bed[i].dorm_number%>|<%=bed[i].number%>号床</label>
        </span>
    <%}%>

</script>
